package com.internetCafes.spms.web.sys.model;

import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.Serializable;
import java.util.Date;


/**
 * 资源信息表
 *
 * @author Sunny
 * @email rekeeper2011@hotmail.com
 * @date 2019-11-27 10:36:49
 */
public class ResourceInfo implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 本表id
	 */
	private Long id;

	/**
	 * 用户id
	 */
	private Long userId;

	/**
	 * 模块标识
	 */
	private String moduleCode;

	/**
	 * 模块id
	 */
	private Long moduleId;

	/**
	 * 配置类型
	 */
	private String confType;

	/**
	 * 配置编码
	 */
	private String confCode;

	/**
	 * 资源名称
	 */
	private String resourceName;

	/**
	 * 资源编号
	 */
	private String resourceCode;

	/**
	 * 主管单位
	 */
	private String releaseDeptName;

	/**
	 * 发放时间
	 */
	private Date releaseTime;

	/**
	 * 有效期至
	 */
	private Date validityEndTime;

	/**
	 * 资源存放地址
	 */
	private String path;

	/**
	 * 创建者
	 */
	private Long createBy;

	/**
	 * 创建时间
	 */
	private Date createTime;

	/**
	 * 资源存放地址
	 */
	private String fileName;


	public ResourceInfo(){}
	public ResourceInfo(Long userId, String moduleCode, Long moduleId, String path) {
		this.userId = userId;
		this.moduleCode = moduleCode;
		this.moduleId = moduleId;
		this.path = path;
		this.createBy = userId;
		this.createTime = new Date();
	}

	public ResourceInfo(Long userId, String moduleCode, Long moduleId, String confType, String confCode, String path) {
		this.userId = userId;
		this.moduleId = moduleId;
		this.moduleCode = moduleCode;
		this.confType = confType;
		this.confCode = confCode;
		this.path = path;
		this.createBy = userId;
		this.createTime = new Date();
	}

	public ResourceInfo(Long userId, String moduleCode, Long moduleId, String confType, String confCode, String resourceName, String path) {
		this.userId = userId;
		this.moduleCode = moduleCode;
		this.moduleId = moduleId;
		this.confType = confType;
		this.confCode = confCode;
		this.resourceName = resourceName;
		this.path = path;
		this.createBy = userId;
		this.createTime = new Date();
	}

	@JSONField(name = "id")
	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	@JSONField(name = "user_id")
	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Long getUserId() {
		return userId;
	}

	@JSONField(name = "module_code")
	public void setModuleCode(String moduleCode) {
		this.moduleCode = moduleCode;
	}

	public String getModuleCode() {
		return moduleCode;
	}

	@JSONField(name = "module_id")
	public void setModuleId(Long moduleId) {
		this.moduleId = moduleId;
	}

	public Long getModuleId() {
		return moduleId;
	}

	@JSONField(name = "conf_type")
	public void setConfType(String confType) {
		this.confType = confType;
	}

	public String getConfType() {
		return confType;
	}

	@JSONField(name = "conf_code")
	public void setConfCode(String confCode) {
		this.confCode = confCode;
	}

	public String getConfCode() {
		return confCode;
	}

	@JSONField(name = "resource_name")
	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}

	public String getResourceName() {
		return resourceName;
	}

	@JSONField(name = "resource_code")
	public void setResourceCode(String resourceCode) {
		this.resourceCode = resourceCode;
	}

	public String getResourceCode() {
		return resourceCode;
	}

	@JSONField(name = "release_dept_name")
	public void setReleaseDeptName(String releaseDeptName) {
		this.releaseDeptName = releaseDeptName;
	}

	public String getReleaseDeptName() {
		return releaseDeptName;
	}

	@JSONField(name = "release_time")
	public void setReleaseTime(Date releaseTime) {
		this.releaseTime = releaseTime;
	}

	public Date getReleaseTime() {
		return releaseTime;
	}

	@JSONField(name = "validity_end_time")
	public void setValidityEndTime(Date validityEndTime) {
		this.validityEndTime = validityEndTime;
	}

	public Date getValidityEndTime() {
		return validityEndTime;
	}

	@JSONField(name = "path")
	public void setPath(String path) {
		this.path = path;
	}

	public String getPath() {
		return path;
	}

	@JSONField(name = "create_by")
	public void setCreateBy(Long createBy) {
		this.createBy = createBy;
	}

	public Long getCreateBy() {
		return createBy;
	}

	@JSONField(name = "create_time")
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public String getFileName() {
		return fileName;
	}

    public String _getFileName() {
        return StringUtils.isNotBlank(path) && path.indexOf(".") > -1? path.substring(0, path.indexOf(".")).replace("pic"+ File.separator, ""):"";
    }

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
}
